package zjc.数组;

public class 动态初始化定义数组 {
    public static void main(String[] args) {
        //先确定数组的长度后再给数组赋值
        //数据类型[] 数据名称 = new 数据类型[长度]
        int[] a = new int[3];
        //默认值为0
        a[1]=3;
        System.out.println(a[0]);
        System.out.println(a[1]);
        //字符默认值是0
        char [] b= new char[100];
        System.out.println((int)b[10]);
        //浮点型数组默认值是0.0
        double[] c=new double[1];
        System.out.println(c[0]);
        //布尔值默认值是false
        boolean[] d=new boolean[1];
        System.out.println(d[0]);
        //引用类型的默认值null
        String[] e=new String[1];
        System.out.println(e[0]);
        //错误示范
        //int[] f=new int[3]{1,2,3};
    }
}
